package com.itheima.reggie.controller;

import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.User;
import com.itheima.reggie.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;


    @PostMapping("/loginout")
    public R userLoginout(HttpSession session){
        return userService.userLoginOut(session);
    }
    //用户登录
    @PostMapping("/login")
    public R userLogin(@RequestBody Map<String,String> map, HttpSession session){
        return userService.userLogin(map,session);
    }
    //发送短信
    @PostMapping("/sendMsg")
    public R sendMsg(@RequestBody User user, HttpSession session){
       return userService.sendMsg(user,session);
    }
}
